<!DOCTYPE html>
<title>Cancel loading a video file and access its properties afterwards.</title>
<video></video>

<textarea style="display: none;">
<!-- Begin child content -->
<!-- The following section contains the content in the document of child window. -->
<script>
var video = window.opener.video;
window.setTimeout(function() {
    var d = video.duration;
    testRunner.notifyDone();
}, 50);
window.opener.blank();
</script>
<!-- End child content -->
</textarea>

<script>
// Access a video element with resource loading canceled.
// If this test is successful it will terminate with a blank page.
// This test should finish without crashing.
testRunner.setPopupBlockingEnabled(false);
testRunner.dumpAsText();

var video = document.querySelector("video");

// Opens a window and writes the child content into the document.
video.onloadedmetadata = function() {
    var win = window.open("", "child");
    var doc = win.document;
    doc.open();
    doc.write(document.querySelector("textarea").value);
    doc.close();
};

var file = "../resources/test.ogv";
video.src = "http://127.0.0.1:8000/media/video-throttled-load.cgi?throttle=40&name=" + file;

// Change URL of the current page to a blank page.
function blank() {
    location.href = "about:blank";
}
</script>